Function Reference

_MouseTrap

Confine the Mouse Cursor to specified coords.

#include <Misc.au3>
_MouseTrap([$i_left = 0[, $i_top = 0[, $i_right = 0[, $i_bottom = 0]]]])

 

Parameters

$i_left Left coord
$i_top Top coord
$i_right Right coord
$i_bottom Bottom coord

 

Return Value

Success: Returns a non zero value
Failure: Returns 0

 

Remarks

Use _MouseTrap() with no params to release the Mouse Cursor

Setting only $i_left and $i_top sets:
    $i_right = $i_left
    $i_bottom = $i_top

 

Related

None.

 

Example


#include <GuiConstants.au3>
#include <Misc.au3>

Opt ("MustDeclareVars", 1)

Dim $GUI, $coords[4], $msg

$GUI = GUICreate("Mouse Trap Example", 392, 323)

GUISetState()

While 1
    $coords = WinGetPos($GUI)
    _MouseTrap ($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            ;;;
    EndSelect
WEnd
_MouseTrap ()
Exit